<?php
/**
 * Create By: PhpStorm
 * User: yihua
 * File: UserFeedback.php
 * Date: 2017/2/7
 * Time: 1:04
 */
namespace app\api\model\dao;

use think\Model;

class UserFeedback extends Model
{
    public function addFeedback($user_id, $content, $feedback_img = null)
    {
        $data = [
            'user_id' => $user_id,
            'content' => $content,
            'create_time' => time(),
        ];
        if (null !== $feedback_img) {
            $data['feedback_img'] = $feedback_img;
        }
        return $this->save($data);
    }

    public function getFeedback($user_id)
    {
        $conds = [
            'user_id' => $user_id,
        ];
        return $this->where($conds)->select();
    }

    public function getCreateTimeAttr($value)
    {
        return date('Y-m-d H:i:s', $value);
    }
}